package com.jielihaofeng.chat.service;

import com.jielihaofeng.framework.common.page.PageResult;
import com.jielihaofeng.framework.common.service.BaseService;
import com.jielihaofeng.chat.vo.ChatUserRelationVO;
import com.jielihaofeng.chat.query.ChatUserRelationQuery;
import com.jielihaofeng.chat.entity.ChatUserRelationEntity;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 用户好友表
 *
 * @author 借力好风 949394048@qq.com
 * @since 1.0.0 2022-07-22
 */
public interface ChatUserRelationService extends BaseService<ChatUserRelationEntity> {

    PageResult<ChatUserRelationVO> page(ChatUserRelationQuery query);

    boolean save(ChatUserRelationVO vo);

    void update(ChatUserRelationVO vo);

    void delete(List<Long> idList);

    List<Long> getFriendIdListByStatus(Long userId, Integer status);

    List<Long> getRequestFriendIdList(Long userId);

    List<ChatUserRelationEntity> getAllFriend(Long userId);

    /**
     * 添加好友
     *
     * @param userId   用户id
     * @param friendId 好友id
     * @return 添加结果
     */
    @Transactional(rollbackFor = Exception.class)
    boolean addFriend(Long userId, Long friendId);

    /**
     * 删除好友
     *
     * @param userId   用户id
     * @param friendId 好友id
     * @return 删除结果
     */
    @Transactional(rollbackFor = Exception.class)
    boolean deleteFriend(Long userId, Long friendId);

    ChatUserRelationEntity queryByUserIdAndFriendId(Long userId, Long friendId);
}